﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Xunit;
using System.Resources;
using MetaSharp.Transformation.Properties;
using NSubstitute;
using System.Threading.Tasks;

namespace MetaSharp.Transformation.Tests.Patterns
{
	public class AnyTests
	{
		[Fact]
		public async Task ReadsCharacterSuccessfully()
		{
            var p = Pattern.Any();
            var m = await Pattern.Match(p, "a");

            Assert.Equal('a', m.Value);
		}

		[Fact]
		public async Task ReadsObjectSuccessfully()
		{
			var expected = new object();
            var p = Pattern.Any();
            var m = await Pattern.Match(p, new[] { expected });
			Assert.Same(expected, m.Value);
		}

		[Fact]
		public async Task FailsToReadEmptyStream()
        {
            var p = Pattern.Any();
            var m = await Pattern.Match(p, "");
			Assert.False(m.Matched);
		}

		[Fact]
		public async Task ReadsExactlyOneInputElement()
        {
            var p = Pattern.Any();
            var m = await Pattern.Match(p, "abc");
            Assert.Equal('b', m.End.Stream.Next().Current);
		}
	}
}
